package org.example.util;

import org.example.dto.ShoppingUser;
/**
 * 饿汉模式,获取interceptor中的传参
 */
public class TUserThreadLocal {

    private static final ThreadLocal<ShoppingUser> threadLocal = new ThreadLocal<>();

    //私有构造函数
    private  TUserThreadLocal() {
    }

    public static void set(ShoppingUser shoppingUser) {
        threadLocal.set(shoppingUser);
    }

    public static ShoppingUser get() {
        return threadLocal.get();
    }

    public static void remove() {
        threadLocal.remove();
    }
}